﻿using System;
using System.Collections.Generic;
using System.Windows.Data;
using System.Windows.Media;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AdTech.Snap.Test
{
    /// <summary>
    /// This is a test class for ValueConverterTest and is intended
    /// to contain all ValueConverterTest Unit Tests
    /// </summary>
    [TestClass()]
    public class ValueConverterTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        /// A test for BrushConverter
        /// </summary>
        [TestMethod()]
        public void BrushConverterTest()
        {
            BrushConverter b = new BrushConverter();
            Assert.IsNull(b.Convert(null, null, null, null));
            Assert.IsNull(b.ConvertBack(null, null, null, null));

            KeyValuePair<string, SolidColorBrush> value = (KeyValuePair<string, SolidColorBrush>)b.Convert(Brushes.Blue, null, null, null);
            Assert.AreEqual("Blue", value.Key);
            Assert.AreEqual(Brushes.Blue.Color, value.Value.Color);

            SolidColorBrush brush = b.ConvertBack(value, null, null, null) as SolidColorBrush;
            Assert.AreEqual(Brushes.Blue.Color, brush.Color);
        }

        /// <summary>
        /// A test for BrushNameConverter
        /// </summary>
        [TestMethod()]
        public void BrushNameConverterTest()
        {
            BrushNameConverter bn = new BrushNameConverter();
            Assert.IsNull(bn.Convert(null, null, null, null));
            Assert.IsNull(bn.ConvertBack(null, null, null, null));

            KeyValuePair<string, SolidColorBrush> value = (KeyValuePair<string, SolidColorBrush>)bn.Convert("AliceBlue", null, null, null);
            Assert.AreEqual("AliceBlue", value.Key);
            Assert.AreEqual(Brushes.AliceBlue.Color, value.Value.Color);

            string name = bn.ConvertBack(value, null, null, null) as string;
            Assert.AreEqual("AliceBlue", name);
        }

        /// <summary>
        /// A test for DropboxUIDConverter
        /// </summary>
        [TestMethod()]
        public void DropboxUIDConverterTest()
        {
            DropboxUIDConverter d = new DropboxUIDConverter();
            Assert.AreEqual(Binding.DoNothing, d.Convert(null, null, null, null));
            bool isException = false;
            try { Assert.IsNull(d.ConvertBack(null, null, null, null)); }
            catch (NotImplementedException) { isException = true; }
            Assert.IsTrue(isException);

            string value = d.Convert(0, null, null, null) as string;
            Assert.AreEqual("Waiting for clipboard changes", value);
            value = d.Convert(666, null, null, null) as string;
            Assert.AreEqual("Successfully extracted UserID: 666", value);
        }
    }
}
